package com.example.Controller;


import com.example.Service.PaintingService;
import com.example.Service.RerankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;


/**
 * ai绘画功能
 */
@RestController
@RequestMapping("/painting")
public class PaintingController {

    @Autowired
    private PaintingService paintingService;

    /**
     *开始绘画
     * @param user
     * @return返回id
     * @throws Exception
     */
    @GetMapping(value = "/run", produces = MediaType.APPLICATION_JSON_VALUE)
    public Map<String, Object> painting(@RequestParam String user) throws Exception {
        String prompt = "。根据以上满足用户的要求";
        String result = paintingService.task_submit(user,prompt);
        System.out.println("返回内容：" + result);
        
        // 将返回数据封装为JSON格式
        Map<String, Object> response = new HashMap<>();
        response.put("status", "success");
        response.put("data", result);
        return response;
    }

    /**
     *根据id查看绘画的图片
     * @param text
     * @return
     * @throws Exception
     */
    @GetMapping(value = "/look", produces = MediaType.APPLICATION_JSON_VALUE)
    public Map<String, Object> Look(@RequestParam String text) throws Exception {
        // text = "bf998bf0c48d57b5a8247851cfcd2875";
        String result = paintingService.taskProgress(text);
        System.out.println("返回内容：" + result);

        // 将返回数据封装为JSON格式
        Map<String, Object> response = new HashMap<>();
        response.put("status", "success");
        response.put("data", result);  // 使用data字段更通用
        return response;
    }
}
